﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Model;
using DAL;

public partial class Teacher_Default2 : System.Web.UI.Page
{
    private string courseId;//课程编号

    protected void Page_Load(object sender, EventArgs e)
    {
        //设置出卷教师

        TeacherManager manager = new TeacherManager();
        Teacher _teacher =  (Teacher)manager.GetModel(Session["id"].ToString());
        teacher.Text = _teacher.name;

        courseId = _teacher.courseId;

        //设置课程名
        CourseManager cmanager = new CourseManager();
        Course _course = (Course)cmanager.GetModel(courseId);
        course.Text = _course.name;

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //添加试卷

        PaperManager manager = new PaperManager();
        Paper paper = new Paper();

        paper.id = Guid.NewGuid().ToString();
        paper.name = papername.Text;
        paper.teacherId = Session["id"].ToString() ;
        paper.totalScore = Int32.Parse(totalScore.Text);
        paper.finishedMinutes = Int32.Parse(finishedMinutes.Text);
        paper.date = DateTime.Now.ToLocalTime();
        paper.courseId = this.courseId;

        try
        {
            manager.Add(paper);
            msg.Text = "添加成功！";
            Response.Redirect("AddQuestionsToPaper.aspx?paperId="+paper.id);
        }
        catch (Exception mye)
        {
            msg.Text = "添加失败，请与管理员联系！";
        }
        

    }
}
